package com.java.module.chat.controller.api;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.java.common.lang.domain.page.Page;
import com.java.common.lang.domain.page.PageDomain;
import com.java.common.service.ApiTokenService;
import com.java.common.utils.WebKit;
import com.java.module.chat.domain.GroupUser;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.java.module.chat.service.IGroupUserService;

/**
 * 聊天模块：群成员Controller
 * 
 * @author Administrator
 * @date 2023-02-16
 */
@RestController("ApiGroupUserController")
@RequestMapping("/chat/user")
public class GroupUserController {

    @Autowired
    IGroupUserService groupUserService;
    @Autowired
    ApiTokenService tokenService;

    @ApiOperationSupport(order = 10)
    @ApiOperation("群聊成员列表")
    @GetMapping("/getGroupUserList")
    public Page<GroupUser> getGroupUserList(GroupUser groupUser, @Validated PageDomain page) {
        groupUser.setUid(tokenService.getLoginUserId());
        return WebKit.getPageData(() -> groupUserService.getGroupUserList(groupUser));
    }
    @ApiOperationSupport(order = 10)
    @ApiOperation("禁言")
    @GetMapping("/changeUserEstoppel")
    public int changeUserEstoppel(GroupUser groupUser) {
         Long loginUserId= tokenService.getLoginUserId();
        return  groupUserService.changeUserEstoppel(groupUser,loginUserId);
    }

}